#include "function.h"


int main()
{
	FILE* file;
	if ((file=fopen("Res1.txt","w"))==0)
		return 1;
	else
	{
		int j=0;
		int count=10000;
		while (j==0)
			scanf("%i", &j);
		double* valueprev=(double*)malloc(sizeof(double)*(j+1));
		double step=10.0/j;
		double h=step*step/2;
		fprintf(file,"%lf\n",step);
		for (int i=0; i<j; i++)
		{
			valueprev[i]=u0(step*i);
		}
		valueprev[j]=0.0;
		double* valuenext=(double*)malloc(sizeof(double)*(j+1));
		for(int k=0; k<count; k++)
		{
			
			valuenext[0]=valueprev[0]+((valueprev[1]-2*valueprev[0]+valueprev[0])/2/step/step-valueprev[0]*h+f1(0))*h;
			for(int i=1; i<j; i++)
			{
				valuenext[i]=valueprev[i]+((valueprev[i+1]-2*valueprev[i]+valueprev[i-1])/2/step/step-valueprev[i]*h+f1(i*step))*h;
			}
			valuenext[j]=valueprev[j]+((valueprev[j]-2*valueprev[j]+valueprev[j-1])/2/step/step-valueprev[j]*h+f1(j*step))*h;
			if(k%100==0)
			{
				fprintf(file,"%i\n",j);
				fprintf(file,"%lf ",valuenext[0]);
				for(int i=1; i<j; i++)
				{
					fprintf(file,"%lf ",valuenext[i]);
				}
				fprintf(file,"%lf\n",valuenext[j]);
			}
			double* tmp=valueprev;
			valueprev=valuenext;
			valuenext=tmp;
		}

	}
}